package com.lxl.workbench.service.impl;

import com.lxl.commons.mapper.IMapper;
import com.lxl.commons.mapper.impl.CategoryStaffMapperImpl;
import com.lxl.commons.mapper.impl.CommonStaffMapperImpl;
import com.lxl.commons.mapper.impl.CuratorMapperImpl;
import com.lxl.settings.entity.User;
import com.lxl.workbench.dao.StaffDao;
import com.lxl.workbench.dao.StaffDaoImpl;
import com.lxl.workbench.entity.Category;
import com.lxl.workbench.entity.CategoryStaff;
import com.lxl.workbench.entity.CommonStaff;
import com.lxl.workbench.entity.Curator;
import com.lxl.workbench.service.StaffService;

import java.sql.SQLException;
import java.util.List;

/**
 * @author 北上寻海
 */
public class StaffServiceImpl implements StaffService {
    StaffDao staffDao = new StaffDaoImpl();
    IMapper commonStaffMapper = new CommonStaffMapperImpl();
    IMapper categoryStaffMapper = new CategoryStaffMapperImpl();
    IMapper curatorMapper = new CuratorMapperImpl();
    @Override
    public List<CommonStaff> queryStaffFromCommon(String staffName, String staffSex) throws SQLException {
        return commonStaffMapper.mapper(staffDao.selectStaffFromCommon(staffName,staffSex));
    }

    @Override
    public List<CategoryStaff> queryStaffFromCategory(String staffName, String staffSex) throws SQLException {
        return categoryStaffMapper.mapper(staffDao.selectStaffFromCategory(staffName,staffSex));
    }



    @Override
    public List<CategoryStaff> selectCategoryStaffByManageType(String categoryId) throws SQLException {
        return categoryStaffMapper.mapper(staffDao.selectCategoryStaffByManageId(categoryId));
    }

    @Override
    public List<CommonStaff> selectCommonStaffById(String id) throws SQLException {
        return commonStaffMapper.mapper(staffDao.selectCommonStaffById(id));
    }

    @Override
    public void promoteStaff(CategoryStaff categoryStaff, String id) throws SQLException {
        staffDao.promoteStaff(categoryStaff,id);
    }

    @Override
    public void resignStaffByIds(String[] delIds,String [] userIds) throws SQLException {
        staffDao.resignStaffByIds(delIds,userIds);
    }

    @Override
    public List<CommonStaff> selectCommonStaffForUserId(String[] delIds) throws SQLException {
        return commonStaffMapper.mapper(staffDao.selectCommonStaffForUserId(delIds));
    }

    @Override
    public List<CategoryStaff> selectCategoryStaffForUserId(String[] delIds) throws SQLException {
        return categoryStaffMapper.mapper(staffDao.selectCategoryStaffForUserId(delIds));
    }

    @Override
    public void demoteStaffByIds(List<CommonStaff> commonStaffList, String[] categoryIds) throws SQLException {
        staffDao.demoteStaff(commonStaffList,categoryIds);
    }

    @Override
    public List<Curator> selectCuratorById(String id) throws SQLException {
        return curatorMapper.mapper(staffDao.selectCuratorById(id));
    }

    @Override
    public List<Curator> selectCuratorByIds(String[] ids) throws SQLException {
        return curatorMapper.mapper(staffDao.selectCuratorByIds(ids));
    }

    @Override
    public void addCommonStaffByCondition(User user, CommonStaff commonStaff) throws SQLException {
        staffDao.addCommonStaffByCondition(user,commonStaff);
    }

    @Override
    public void addCategoryStaffByCondition(User user, CategoryStaff categoryStaff) throws SQLException {
        staffDao.addCategoryStaffByCondition(user,categoryStaff);
    }
}
